Skip to content

Conversation

@samwillis
Copy link
Collaborator

@samwillis samwillis commented Jan 15, 2026

Summary

  • Configure the changesets-release job to use npm's Trusted Publishing feature instead of long-lived npm tokens
  • Uses OpenID Connect (OIDC) for authentication, providing better security through short-lived, workflow-specific credentials
  • Removes dependency on NPM_TOKEN secret

Why Trusted Publishing?

Trusted publishing eliminates the security risks associated with long-lived npm tokens:

  • No token exposure risk - Tokens can be accidentally exposed in logs or compromised; OIDC uses short-lived, cryptographically-signed credentials
  • No manual rotation needed - Each publish uses automatically-generated, workflow-specific credentials
  • Scoped access - Credentials are specific to the configured workflow and cannot be extracted or reused
  • Automatic provenance - npm automatically generates provenance attestations when publishing via trusted publishing

Changes

  • Added id-token: write permission to the changesets-release job (required for GitHub Actions to generate OIDC tokens)
  • Removed NPM_TOKEN secret from the workflow (no longer needed with trusted publishing)
  • Upgraded to Node.js 24 for the changesets-release job (npm trusted publishing requires npm 11.5.1+, which is bundled with Node.js 24)

Configuration

Trusted publishers have been configured on npmjs.com for all packages with:

  • Publisher: GitHub Actions
  • Organization: electric-sql
  • Repository: pglite
  • Workflow filename: build_and_test.yml
image

Documentation

Test plan

  • Merge and trigger a release via changesets
  • Verify packages publish successfully using OIDC authentication
  • Confirm provenance attestations are generated on published packages

Post-merge recommendation

After verifying trusted publishing works correctly, consider restricting token-based publishing access on npmjs.com by navigating to each package's Settings → Publishing access and selecting "Require two-factor authentication and disallow tokens" for maximum security.

Configure the changesets-release job to use npm's Trusted Publishing
feature instead of long-lived npm tokens. This uses OpenID Connect
(OIDC) for authentication, providing better security through short-lived,
workflow-specific credentials.

Changes:
- Add id-token: write permission for OIDC token generation
- Remove NPM_TOKEN secret (no longer needed with trusted publishing)

See: https://docs.npmjs.com/trusted-publishers
npm trusted publishing requires npm 11.5.1+, which is bundled
with Node.js 24 (npm 11.6.2). Node.js 20 only includes npm 10.8.2.
@samwillis samwillis requested a review from tdrz January 15, 2026 09:40
Copy link
Collaborator

@tdrz tdrz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@github-actions
Copy link
Contributor

@tdrz tdrz merged commit 9615075 into main Jan 15, 2026
14 checks passed
@tdrz tdrz deleted the trusted-publishing branch January 15, 2026 09:51
@github-actions
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants